<!DOCTYPE html>
<html>
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">
<div class="wrapper wrapper-content ">
    <div class="row">
        <div class="col-sm-12">
            <div class="ibox float-e-margins">
                <div class="ibox-content">
                    <form class="form-horizontal m-t" id="signupForm">
                        <div class="form-group">
                            <label class="col-sm-3 control-label">产品名称：</label>
                            <div class="col-sm-8">
                                <select onchange="getDistrict()" id="productid" name="productid" class="form-control"
                                        type="text"></select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">频道名称：</label>
                            <div class="col-sm-8">
                                <select id="catalogid" name="catalogid"
                                        class="form-control" type="text">
                                    <option value="">---请选择频道---</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">广告位名称：</label>
                            <div class="col-sm-8">
                                <input maxlength="30" id="advpositionname" name="advpositionname" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">广告位类型：</label>
                            <div class="col-sm-8">
                                <select id="advpositiontype" onchange="getType();" name="advpositiontype"
                                        class="form-control"
                                        type="text"></select>
                            </div>
                        </div>
                        <div class="form-group" id="aaaa" style="display: none;">
                            <label class="col-sm-3 control-label">广告间隔：</label>
                            <div class="col-sm-8">
                                <input onkeyup="this.value=this.value.replace(/\D/g,'')"
                                       onafterpaste="this.value=this.value.replace(/\D/g,'')" maxlength="10"
                                       id="advInterval" name="advInterval" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">广告位宽：</label>
                            <div class="col-sm-8">
                                <input maxlength="30" id="advpositionwide" name="advpositionwide" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">广告位高：</label>
                            <div class="col-sm-8">
                                <input maxlength="30" id="advpositionheight" name="advpositionheight"
                                       class="form-control" type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片尺寸描述：</label>
                            <div class="col-sm-8">
                                <input maxlength="30" id="imgsizedes" name="imgsizedes" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片比例描述：</label>
                            <div class="col-sm-8">
                                <input maxlength="30" id="imgscaledes" name="imgscaledes" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">图片格式描述：</label>
                            <div class="col-sm-8">
                                <input maxlength="30" id="imgformatdes" name="imgformatdes" class="form-control"
                                       type="text">
                            </div>
                        </div>
                        <div class="form-group">
                            <label class="col-sm-3 control-label">支持SSP：</label>
                            <div class="col-sm-8">
                                <select id="isssp" name="isssp"
                                        class="form-control">
                                    <option value="1">支持</option>
                                    <option value="0">不支持</option>
                                </select>
                            </div>
                        </div>
                        <div class="form-group">
                            <div class="col-sm-8 col-sm-offset-3">
                                <button type="submit" class="btn btn-primary">提交</button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
<div th:include="include::footer"></div>
<script type="text/javascript" src="/js/appjs/market/productAdvposition/add.js">
</script>
<script type="text/javascript" th:inline="javascript">
    function getDistrict() {
        $("#catalogid").empty();    //清空二级下拉框，否则会叠加
        // $("#sdkid").append("<option value='' selected='selected'>" + "---请选择---" + "</option>");
        /* var id = obj.id;
         var options = $("#" + id + " option:selected"); //获取选中的项
         alert(options.text()); //拿到选中项的值
         var countrycode = options.val();*/
        var productid = $("#productid").val();
        $.ajax({
            type: "post",
            url: '/market/productCatalog/listAllCatalogs',
            dataType: 'json',
            data: {productid: productid},
            success: function (data) {
                var select = $("#catalogid");
                for (var i = 0; i < data.length; i++) {
                    select.append("<option value='" + data[i].id + "'>"
                        + data[i].catalogName + "</option>");
                }
            }
        });
    }

    $(function () {
        $.ajax({
            type: 'get',
            url: '/market/productChannel/listAllProduct?channelid=' + $("#channelid").val(),
            dataType: 'json',
            success: function (datas) {
                //返回list数据并循环获取
                var select = $("#productid");
                for (var i = 0; i < datas.length; i++) {
                    select.append("<option value='" + datas[i].id + "'>"
                        + datas[i].productName + "</option>");
                }
                getDistrict();
            }
        });
        $.ajax({
            type: 'get',
            url: '/market/productAdvposition/listProductAdvpositionType',
            dataType: 'json',
            success: function (datas) {
                //返回list数据并循环获取
                var select = $("#advpositiontype");
                select.append("<option value=''>"
                    + "---请选择---" + "</option>");
                for (var i = 0; i < datas.length; i++) {
                    select.append("<option value='" + datas[i].advPositionType + "'>"
                        + datas[i].advPositionTypeName + "</option>");
                }
            }
        });
    })

    function getType() {
        var advpositiontype = $("#advpositiontype").val();
        $("#advInterval").val("");
        if (advpositiontype == 1) {
            $("#aaaa").show();
        } else {
            $("#aaaa").hide();
        }
    }
</script>
</body>
</html>
